﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TCC.CMFlow.Contexts;
using TCC.CMFlow.Controllers;
using TCC.CMFlow.Models;
using TCC.CMFlow.Models.Enumerators;

namespace TCC.CMFlow.Business
{
    public static class Logger
    {
        public static void AddLog(EnumTipoLog tipoLog, int? moduloID, string userID, string mensagem)
        {
            DataContext db = new DataContext();

            try
            {
                LogSistema log = new LogSistema();
                log.UsuarioID = userID;
                log.NomeEstacao = Environment.MachineName;
                log.DataHoraAcao = DateTime.Now;
                log.Mensagem = mensagem;
                log.ModuloID = moduloID;
                log.TipoLog = (int)tipoLog;

                db.LogSistema.Add(log);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Dispose();
            }
        }
    }
}